home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / smallc.arc / ROMAN.C < prev    next >
Text File  |  1985-07-17  |  1KB  |  50 lines

  1.  
  2. /*
  3. ** Print numbers fron 1 to 25 as Roman numerals.
  4. */
  5. main()
  6.         {
  7.         int x = 1;
  8.         printf("This program prints out Roman Numerals\n");
  9.         while (x <= 25)  {
  10.                 roman (x);
  11.                 x = x + 1 ;
  12.                 }
  13.         printf("\n\nI hope you liked it!\n");
  14.         }
  15.  
  16. /*
  17. ** Print an Arabic number in Roman numerals.
  18. */
  19. roman(arabic)
  20. int arabic;
  21.         {
  22.         arabic = romanize(arabic,1000,'m');
  23.         arabic = romanize(arabic,500,'d');
  24.         arabic = romanize(arabic,100,'c');
  25.         arabic = romanize(arabic,50,'l');
  26.         arabic = romanize(arabic,10,'x');
  27.         arabic = romanize(arabic,5,'v');
  28.         arabic = romanize(arabic,1,'i');
  29.         romanize(arabic,1,'i');
  30.         printf("\n");
  31.         }
  32.  
  33. /*
  34. ** Print the character c as many times as there are
  35. ** j's in the number i, then return i minus the j's
  36. */
  37. romanize (i,j,c)
  38. char c;
  39. int i,j;
  40.         {
  41.         while (i>=j)
  42.                 {
  43.                 putch(c);
  44.                 i = i - j;
  45.                 }
  46.         return i;
  47.         }
  48.  
  49.  
  50.